<%-- <%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@page import="org.quickbundle.orgauth.util.impl.RmOrgService"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.quickbundle.project.common.vo.RmCommonVo"%>
<%@page import="org.quickbundle.project.RmProjectHelper"%>
<%@ page import="java.util.List" %>
<%@page import="org.quickbundle.tools.helper.RmVoHelper"%>
<%@page import="org.quickbundle.tools.helper.RmJspHelper"%>
<%@page import="org.quickbundle.project.RmGlobalReference"%>
<%@page import="org.quickbundle.base.web.page.RmPageVo"%>
<%@ page import="org.quickbundle.orgauth.rmuser.vo.RmUserVo" %>
<%@ page import="org.quickbundle.orgauth.rmuser.util.IRmUserConstants" %>
<%@page import="org.quickbundle.base.beans.factory.RmBeanFactory"%>
<%@page import="org.quickbundle.orgauth.IOrgauthConstants"%>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<%@ taglib uri="/dfhc" prefix="dfhc" %>
<!-- 全局js 和css包 -->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/ztree/demo.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/jquery.ztree.excheck-3.5.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/js/h-ui.admin/jquery.validation/1.14.0/messages_zh.js"></script> 

<title>用户管理</title>
</head>
<script type="text/javascript">
		var child_party_id='';
		var child_party_name='';
		var child_party_code='';
		var setting = {
			async: {
			enable: true,
			url:"<%=request.getContextPath()%>/pubController/ajaxGetParty?is_allow_hanging_user=1",
			autoParam:["child_party_code"],
			otherParam:{},
			dataFilter: filter
		  },
		  callback: {
			  beforeClick: beforeClick1,
			  beforeAsync: beforeAsync,
			  onAsyncError: onAsyncError,
			  onAsyncSuccess: onAsyncSuccess
			  }
		};
		function filter(treeId, parentNode, childNodes) {
			if (!childNodes) return null;			
			var childNodes= childNodes.trees;
			if (!childNodes) return null;
			for (var i=0, l=childNodes.length; i<l; i++) {		
				childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
				if(childNodes[i].is_leaf=='1'){
					childNodes[i].isParent=false;
				}else{
					childNodes[i].isParent=true;
				}
			}
			return childNodes;
		}
		function beforeClick1(treeId, treeNode) {
			child_party_id = treeNode.child_party_id;
			child_party_name = treeNode.name;
			child_party_code = treeNode.child_party_code; 
			$("#organizationName").val(child_party_name);
			$("#organizationId").val(child_party_id);
			if(treeNode.is_leaf=='1'){
					treeNode.isParent=false;
				}else{
					treeNode.isParent=true;
				}
    	   $("#organizationContent").css({
    		left:0,
    		top:0,
    		display:"none",
    		width:0
    	   }).fadeOut("fast");				
			if (!treeNode.isParent) {
				return false;
			} else {
				return true;
			}
		}
		var log, className = "dark";
		function beforeAsync(treeId, treeNode) {
			className = (className === "dark" ? "":"dark");
			showLog("[ "+getTime()+" beforeAsync ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root") );
			return true;
		}
		function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
			showLog("[ "+getTime()+" onAsyncError ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root") );
		}
		function onAsyncSuccess(event, treeId, treeNode, msg) {
			showLog("[ "+getTime()+" onAsyncSuccess ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root") );
		}
		
		function showLog(str) {
			if (!log) log = $("#log");
			log.append("<li class='"+className+"'>"+str+"</li>");
			if(log.children("li").length > 8) {
				log.get(0).removeChild(log.children("li")[0]);
			}
		}
		function getTime() {
			var now= new Date(),
			h=now.getHours(),
			m=now.getMinutes(),
			s=now.getSeconds(),
			ms=now.getMilliseconds();
			return (h+":"+m+":"+s+ " " +ms);
		}	  
		
		
</script>

<body>
	<div style="z-index: 9999; display: none;" id="organizationContent">
		<div class="zTreeDemoBackground">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</div>
	
<dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiBodyTemp" >	 
 	<dfhc:region name="searchRegion"> 
	<form name="searchForm" id="searchForm" action="">
 	<dfhc:div templateId="h_ui_div_search">
 		用户：
		<dfhc:input templateId="h_ui_search_input" placeholder="输入用户名" id="name" name="name"/>
		登录账号：
		<dfhc:input templateId="h_ui_search_input" placeholder="输入登录账号" id="login_id" name="login_id"/>
		邮箱：
		<dfhc:input templateId="h_ui_search_input" placeholder="输入邮箱" id="email" name="email"/>
		<dfhc:button templateId="h_ui_search_button"  onclick="javascript:_searchData();" />
		<dfhc:button templateId="h_ui_reset_button"  onclick="javascript:_reset('#searchForm');" />
	</dfhc:div> 
	</form>
     </dfhc:region> 
     <dfhc:region name="buttonRegion">
        <dfhc:div templateId="h_ui_div_table_button">
        <dfhc:span templateId="h_ui_button_span">
         <dfhc:button templateId="h_ui_add_button" onclick="_showPage('添加用户','${pageContext.request.contextPath }/newRmUser/addPage','850','650')" />
         <dfhc:button templateId="h_ui_update_button" onclick="singleEdit('修改用户','${pageContext.request.contextPath }/newRmUser/showPage','850','650')" />
		 <dfhc:button templateId="h_ui_delete_button" onclick="singleDelete('${pageContext.request.contextPath }/newRmUser/delete')" />
		 <dfhc:button templateId="h_ui_author_button" onclick="singleAuthor('用户权限设置','${pageContext.request.contextPath }/newRmUser/author','850','650')" />
		 <dfhc:button templateId="h_ui_resetpassword_button" onclick="resetPassword('${pageContext.request.contextPath }/newRmUser/reSetPassword')" />
		 <dfhc:button templateId="h_ui_detail_button" onclick="detail('用户详情','${pageContext.request.contextPath }/newRmUser/detail','850','650')" />
		</dfhc:span>
		<dfhc:span templateId="h_ui_total_record_num_span">${RM_PAGE_VO.recordCount}</dfhc:span>		
	    </dfhc:div>		       
     </dfhc:region> 
    <dfhc:region name="tableRegion">
    	<dfhc:table templateId="table_h_ui" >    	
		<dfhc:thead>
			<dfhc:tr> 
				<dfhc:th width="25">
				   <dfhc:checkbox name="allId" />
				</dfhc:th>	
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("name")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("lock_status")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("login_id")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >所属组织：
				  </dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("employee_id")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("email")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("admin_type")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("login_status")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("last_login_date")%></dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("last_login_ip")%></dfhc:title>
				</dfhc:th>
				
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" ><%=IRmUserConstants.TABLE_COLUMN_CHINESE.get("login_sum")%></dfhc:title>
				</dfhc:th>
			</dfhc:tr>
    	   </dfhc:thead>			
		</dfhc:table>           
     </dfhc:region>        
     <dfhc:region name="footer"> 
     </dfhc:region> 
</dfhc:template>    

<script type="text/javascript">
var neww;
var newh;
var _table;
$(function(){

	_table = $('.table-sort').dataTable({	
	     dom: 'Zlfrtip',	 
	     
		 ajax : function(data, callback, settings) {
		       var param =  splitParameter(data); 
		       
                 $.ajax({  
                        type: "GET",  
                        url: getRootPath()+"/newRmUser/ajaxList?jsguid=<%=session.getId()%>",  
                        cache : false,  //禁用缓存  
                        data:param,   
                        dataType: "json",  
                        success: function(result) {  
                                //异常判断与处理  
                                if (result.status=='0') {  
                                    alert(result.message);  
                                    return;  
                                }  
                                //封装返回数据  
                                var returnData = {};  
                                returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回  
                                returnData.recordsTotal = result.recordsTotal;//总记录数  
                                returnData.recordsFiltered = result.recordsTotal;//后台不实现过滤功能，每次查询均视作全部结果  
                                returnData.data = result.data;  
                                //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染  
                                //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕  
                                callback(returnData);  
                                //更新总记录数
                                $("#totalRecodSpan").html('共有数据：<strong>'+result.recordsTotal+'</strong> 条</span>');
                        },  
                        error: function(XMLHttpRequest, textStatus, errorThrown) {  
                            alert("查询失败");  
                        }  
                    });   
            },  
		"columns": [
		  {
		    "data":"id",
			"render":function(data,type,row,meta){
			   var content='<input type="checkbox" name="allId" value="'+row.id+'"/>';
			   return content; 
			}
		  },
		  {"data":"name"},
		  {"data":"lock_status"},
		  {"data":"login_id"},
		  {"data":"custom5"},
		  {"data":"employee_id"},
		  {"data":"email"},
		  {"data":"admin_type"},
		  {"data":"login_status"},
		  {	   
		    "data":"createTime",
		    "defaultContent":"",
			render:function(data,type,row,meta){
			   var content=formatDate(row.createTime,'yyyy-MM-dd');			 
			   return content; 
			}
		  },
		  {"data":"last_login_ip"},
		  {"data":"login_sum"}	  
		],
		"columnDefs": [ {"searchable": false,
            "orderable": false,
            "targets": 0 }]  				
	});
	$.fn.zTree.init($("#treeDemo"), setting);
	//点击选择组织,
    $('#organizationName').on('focus',function(){
    	var origanizationObj = $("#organizationName");
    	var organizationContentObj = $("#organizationContent");
    	var origanizationOffset = $("#organizationName").offset();
    	var top = (origanizationOffset.top + origanizationObj.outerHeight()-organizationContentObj.outerHeight())+"px";    	
    	$("#organizationContent").css({
    	left:origanizationOffset.left+"px",
    	top:(origanizationOffset.top -organizationContentObj.outerHeight())+80+"px",
    	display:"block",
    	width:(origanizationObj.outerWidth()-3)+"px",
    	position:"absolute"
    	}).slideDown("fast");
    	
    	$("body").bind("mousedown",function(){
    	   if(!(event.target.id =="organizationContent" || $(event.target).parents("#organizationContent").length>0)){
    	   $("#organizationContent").css({
    		left:0,
    		top:0,
    		display:"none",
    		width:0
    	   }).fadeOut("fast");
    	   }
    	});
    });
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
});
/*拼接参数*/
function splitParameter(data){
	 //var paramJsonStr = formToJson(decodeURIComponent($(searchForm).serialize(),true));
	 var paramJsonStr = $(searchForm).serializeObject();
	 //组装 排序参数
	 if(data.order && data.order.length && data.order[0]){
	  data.sort = data.columns[data.order[0].column].data;
      if(data.sort!='0'){
      	data.dir = data.order[0].dir;
      }else{
        data.sort ='';
        data.dir='';
      }
	}  
	var retVal;
	retVal = $.extend( {}, data,paramJsonStr); 
	return retVal;
}


$.fn.serializeObject=function(){
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

/**
 * 查询用户
 */
function _searchData(){	
	$('.table-sort').DataTable().ajax.reload();
} 
//重置
function _reset(obj) {

	$(obj).find("input").each(function() {
				if(!$(this).is(":hidden")){
					$(this).val("");
				}
			});
	$(obj).find("select").each(function() {
				$(this).val("");
			});
}
//授权
function singleAuthor(title,url,w,h){
	var len = $('input[name="allId"]:checked').length;
    var count=0;
    var ids='';
     $('input[name="allId"]:checked').each(function(){
     	
     	var dataId =$(this).val();
     	if(dataId !== undefined && dataId!='on'){
     		ids+=dataId
         	if(len!=1){
         		ids+=","
         	}
         	count++;
     	}
     });  
    if(count==0){
       alert("请选择记录!");
       return;
    }  
    
    if(count>1){
       alert("只能选择一条记录!");
       return;	
    }
    var newUrl ;
    if(url.indexOf("?")>=0){
    	newUrl = url+'&id='+ids+'&jsguid='+ids;
    }else{
    	newUrl = url+'?id='+ids+'&jsguid='+ids;
    }
	var neww;
    var newh;
    
    if(w.indexOf("%")!=-1){
      neww = w; 
    }else{
      neww = w+'px';
    }
    if(h.indexOf("%")!=-1){
      newh = h; 
    }else{
      newh = h+'px';
    }
	layer.open({
			type: 2,
			area: [neww, newh],
			fix: true,
			shade:0.4,
			title: title,
			content: newUrl,
            maxmin:true,
			cancel:function(){
				window.location.reload();
			}
	});
	
}

//详情
function detail(title,url,w,h){
	//判断用户是否选择
	var len = $('input[name="allId"]:checked').length;
    var count=0;
    var ids='';
     $('input[name="allId"]:checked').each(function(){
     	
     	var dataId =$(this).val();
     	if(dataId !== undefined && dataId!='on'){
     		ids+=dataId
         	if(len!=1){
         		ids+=","
         	}
         	count++;
     	}
     });  
    if(count==0){
       alert("请选择记录!");
       return;
    }  
    
    if(count>1){
       alert("只能选择一条记录!");
       return;	
    }
    var newUrl ;
    if(url.indexOf("?")>=0){
    	newUrl = url+'&id='+ids+'&jsguid='+ids;
    }else{
    	newUrl = url+'?id='+ids+'&jsguid='+ids;
    }
	var neww;
    var newh;
    
    if(w.indexOf("%")!=-1){
      neww = w; 
    }else{
      neww = w+'px';
    }
    if(h.indexOf("%")!=-1){
      newh = h; 
    }else{
      newh = h+'px';
    }
	layer.open({
			type: 2,
			area: [neww, newh],
			fix: true,
			shade:0.4,
			title: title,
			content: newUrl,
            maxmin:true,
			cancel:function(){
				window.location.reload();
			}
	});
}
//重置密码
function resetPassword(url){
	var len = $('input[name="allId"]:checked').length;
    var count=0;
    var ids='';
     $('input[name="allId"]:checked').each(function(){     	
     	var dataId =$(this).val();
     	if(dataId !== undefined && dataId!='on'){
     		ids+=dataId
         	if(len!=1){
         		ids+=","
         	}
         	count++;
     	}
     });  
    if(count==0){
       alert("请选择删除的记录!");
       return;
    }  
    
    if(count>1){
       alert("只能选择一条记录!");
       return;	
    }
    newUrl=url+"?ids="+ids;
	layer.confirm('确认要重置吗？',function(index){
		$.ajax({
			type: 'POST',
			url: newUrl,
			dataType: 'json',
			success: function(data){
				//$(obj).parents("tr").remove();
				layer.msg('重置成功!',{icon:1,time:1000});
				$('.table-sort').DataTable().ajax.reload();
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script> 
</body>
</html> --%>